<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>微信授权服务 - 首页</title>
    <style>
      :root {
        --primary-color: #07c160;
        --primary-hover: #06ae56;
        --secondary-color: #2196f3;
        --text-color: #333;
        --bg-color: #f5f5f5;
        --card-bg: #ffffff;
        --border-color: #e0e0e0;
      }

      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }

      body {
        font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
        line-height: 1.6;
        color: var(--text-color);
        background-color: var(--bg-color);
        min-height: 100vh;
      }

      .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 20px;
      }

      .header {
        text-align: center;
        margin-bottom: 40px;
        padding: 40px 20px;
        background: linear-gradient(
          135deg,
          var(--primary-color),
          var(--secondary-color)
        );
        color: white;
        border-radius: 12px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
      }

      .header h1 {
        font-size: 2.5rem;
        margin-bottom: 10px;
      }

      .header p {
        font-size: 1.2rem;
        opacity: 0.9;
      }

      .features {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 30px;
        margin-bottom: 40px;
      }

      .feature-card {
        background: var(--card-bg);
        padding: 30px;
        border-radius: 12px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        text-align: center;
        transition: transform 0.3s ease, box-shadow 0.3s ease;
      }

      .feature-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
      }

      .feature-icon {
        font-size: 3rem;
        margin-bottom: 20px;
      }

      .feature-card h3 {
        color: var(--primary-color);
        margin-bottom: 15px;
        font-size: 1.3rem;
      }

      .feature-card p {
        color: #666;
        line-height: 1.6;
      }

      .actions {
        display: flex;
        justify-content: center;
        gap: 20px;
        flex-wrap: wrap;
        margin: 40px 0;
      }

      .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 12px 24px;
        border: none;
        border-radius: 8px;
        font-size: 16px;
        font-weight: 500;
        text-decoration: none;
        cursor: pointer;
        transition: all 0.3s ease;
        min-width: 160px;
      }

      .btn-primary {
        background: var(--primary-color);
        color: white;
      }

      .btn-primary:hover {
        background: var(--primary-hover);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(7, 193, 96, 0.3);
      }

      .btn-secondary {
        background: var(--secondary-color);
        color: white;
      }

      .btn-secondary:hover {
        background: #1976d2;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
      }

      .btn-outline {
        background: transparent;
        color: var(--primary-color);
        border: 2px solid var(--primary-color);
      }

      .btn-outline:hover {
        background: var(--primary-color);
        color: white;
      }

      .api-info {
        background: var(--card-bg);
        padding: 30px;
        border-radius: 12px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        margin-top: 40px;
      }

      .api-info h2 {
        color: var(--primary-color);
        margin-bottom: 20px;
        text-align: center;
      }

      .endpoint {
        background: #f8f9fa;
        padding: 15px;
        border-radius: 8px;
        margin: 10px 0;
        border-left: 4px solid var(--primary-color);
      }

      .endpoint .method {
        display: inline-block;
        background: var(--primary-color);
        color: white;
        padding: 4px 8px;
        border-radius: 4px;
        font-size: 12px;
        font-weight: bold;
        margin-right: 10px;
      }

      .endpoint .path {
        font-family: "Courier New", monospace;
        color: #333;
      }

      .footer {
        text-align: center;
        margin-top: 60px;
        padding: 20px;
        color: #666;
        border-top: 1px solid var(--border-color);
      }

      @media (max-width: 768px) {
        .header h1 {
          font-size: 2rem;
        }

        .features {
          grid-template-columns: 1fr;
        }

        .actions {
          flex-direction: column;
          align-items: center;
        }

        .btn {
          width: 100%;
          max-width: 300px;
        }
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="header">
        <h1>🚀 微信授权服务</h1>
        <p>完整的微信扫一扫授权解决方案</p>
      </div>

      <div class="features">
        <div class="feature-card">
          <div class="feature-icon">🔐</div>
          <h3>安全授权</h3>
          <p>
            支持微信网页授权，安全获取用户openid和基本信息，符合微信官方规范。
          </p>
        </div>

        <div class="feature-card">
          <div class="feature-icon">⚡</div>
          <h3>高性能</h3>
          <p>优化的后端架构，支持高并发请求，内置请求频率限制和安全防护。</p>
        </div>

        <div class="feature-card">
          <div class="feature-icon">🎯</div>
          <h3>易于部署</h3>
          <p>提供Docker支持，一键部署，支持环境变量配置，适合各种部署环境。</p>
        </div>
      </div>

      <div class="actions">
        <a href="/auth" class="btn btn-primary">开始授权</a>
        <a href="/demo" class="btn btn-secondary">查看演示</a>
        <a href="/api/info" class="btn btn-outline">API信息</a>
      </div>

      <div class="api-info">
        <h2>📡 API 接口</h2>
        <div class="endpoint">
          <span class="method">GET</span>
          <span class="path">/api/auth/openid?code={code}</span>
          <p>使用微信授权code换取用户openid</p>
        </div>
        <div class="endpoint">
          <span class="method">GET</span>
          <span class="path"
            >/api/auth/userinfo?access_token={token}&openid={openid}</span
          >
          <p>获取用户基本信息</p>
        </div>
        <div class="endpoint">
          <span class="method">GET</span>
          <span class="path"
            >/api/auth/check-token?access_token={token}&openid={openid}</span
          >
          <p>验证access_token有效性</p>
        </div>
        <div class="endpoint">
          <span class="method">GET</span>
          <span class="path">/api/health</span>
          <p>健康检查接口</p>
        </div>
      </div>

      <div class="footer">
        <p>© 2025 微信授权服务 | 基于 Node.js + Express 构建</p>
      </div>
    </div>

    <script>
      // 页面加载完成后的初始化
      document.addEventListener("DOMContentLoaded", function () {
        console.log("微信授权服务首页已加载");

        // 添加简单的交互效果
        const buttons = document.querySelectorAll(".btn");
        buttons.forEach((button) => {
          button.addEventListener("mouseenter", function () {
            this.style.transform = "translateY(-2px)";
          });

          button.addEventListener("mouseleave", function () {
            this.style.transform = "translateY(0)";
          });
        });
      });
    </script>
  </body>
</html>
